import http from '@/utils/request'
/**
 * 将用户频道保存到 Redux
 */
export const setUserChannels = (channels) => {
  return {
    type: 'home/channel',
    payload: channels,
  }
}

/**
 * 获取频道
 */
export const getUserChannels = () => {
  return async (dispatch) => {
    // 请求数据
    const res = await http.get('user/channels')
    const { channels } = res.data

    // 将频道数据保存到 Redux
    dispatch(setUserChannels(channels))
  }
}
